cmake_minimum_required(VERSION 3.0)
find_package(PythonInterp REQUIRED)
project(torch_demo)
set(CMAKE_CXX_STANDARD 14)
#set(CMAKE_BUILD_TYPE "Debug")


if(CMAKE_BUILD_TYPE AND (CMAKE_BUILD_TYPE STREQUAL "Debug"))
    set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -O0 ${TORCH_CXX_FLAGS} ")
    message("Debug mode:${CMAKE_C_FLAGS_DEBUG}")
elseif(CMAKE_BUILD_TYPE AND (CMAKE_BUILD_TYPE STREQUAL "Release"))
    set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -Wall -Wextra ${TORCH_CXX_FLAGS} ")
    message("Release mode:${CMAKE_C_FLAGS_RELEASE}")
else()
    message("else:${CMAKE_BUILD_TYPE}")
    message("else:${CMAKE_C_FLAGS_RELEASE}")
    #add_executable(test_release ${src_dirs})
endif()
FIND_PACKAGE(OpenMP REQUIRED)
if (OPENMP_FOUND)
    message("OPENMP FOUND")
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif ()

#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPTION} ${TORCH_CXX_FLAGS} ")
message(STATUS"Build type: ${CMAKE_BUILD_TYPE}")
set(CUDA_INCLUDE_DIRS "/usr/local/cuda/include")
set(CMAKE_CUDA_COMPILER /usr/local/cuda/bin/nvcc)
#set(Torch_DIR  "/home/qiyao/LIBS/libtorch/share/cmake/Torch")
set(Torch_DIR  "${PROJECT_SOURCE_DIR}/libtorch/share/cmake/Torch")

find_package(Torch REQUIRED)
include_directories(${TORCH_INCLUDE_DIRS})

find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})

message(STATUS "    OpenCV library status:")
message(STATUS "    config: ${OpenCV_DIR}")
message(STATUS "    version: ${OpenCV_VERSION}")
message(STATUS "    libraries: ${OpenCV_LIBS}")
message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")
message(STATUS "    libtorch library status:")
message(STATUS "    config: ${Torch_DIR}")
message(STATUS "    version: ${Torch_VERSION}")

#link_directories("${PROJECT_DIR}/MVS/lib/64")
include_directories(${PROJECT_SOURCE_DIR})
include_directories("${PROJECT_SOURCE_DIR}/MVS/include" "/usr/include/X11" "/usr/include")

#link_libraries("${PROJECT_DIR}/MVS/lib/64/libMvCameraControl.so")

#add_executable(torch_demo main.cpp)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR})
add_executable(torch_demo with_frame.cpp)
add_library(segnet SHARED SIGNET/network.cpp)
add_library(orb SHARED orb/orb.cpp)
add_library(camera_class SHARED CAMERA/camera_class.cpp)
add_library(algroth SHARED CAMERA/algroth.cpp)
add_library(parameter_reader SHARED SRC/parameter_reader.cpp)

target_include_directories(torch_demo PRIVATE CUDA_INCLUDE_DIRS)

target_link_libraries(torch_demo ${TORCH_LIBRARIES} ${OpenCV_LIBS} )
#target_link_libraries(torch_demo libMvCameraControl.so -lX11)
target_link_libraries(torch_demo algroth  segnet camera_class orb parameter_reader)







